﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;
using System.Data;
using System.Web.UI.HtmlControls;
namespace BookShopSys
{
    public partial class BookText : System.Web.UI.Page
    {
        liber model = new liber();
        liberBLL bll = new liberBLL();
        ManageBLL bllm = new ManageBLL();
        List<CartInfo> listCart = null;
        public string pid = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["PID"]))
                {
                    pid = Request.QueryString["PID"];
                    model.liberID = Convert.ToInt32(Request.QueryString["PID"]);
                    ShowList();
                }
            }
        }
        public void ShowList()
        {
            DataTable dt = bll.GetDataByID(model); //获取DataTable数据
            List<liber> list = new List<liber>();
            /*循环遍历DataTable 并赋值给StudentInfo模型*/
            foreach (DataRow item in dt.Rows)
            {
                liber stu = new liber();//必须要在这里实例化，不然泛型集合里面的数据
                stu.liberCont = item["liberCont"].ToString();
                stu.liberConut = item["liberConut"].ToString();
                stu.liberName = item["liberName"].ToString();
                stu.ManageID = item["ManageID"].ToString();
                stu.liberMoney = item["liberMoney"].ToString();
                stu.liberTitle = item["liberTitle"].ToString();
                stu.liberJianjie = item["liberJianjie"].ToString();
                list.Add(stu);//将模型数据添加到泛型集合
            }
            this.Repeater1.DataSource = list;
            this.Repeater1.DataBind();
        }
        ////public void AddCart()
        ////{
        ////    if (Session["cp"] != null)
        ////    {
        ////        listCart = Session["cp"] as List<CartInfo>;
        ////        bool isExist = false;
        ////        foreach (CartInfo item in listCart)
        ////        {
        ////            if (Request.QueryString["PID"] == item.ID.ToString())
        ////            {
        ////                item.Num = item.Num + 1;
        ////                isExist = true;
        ////                break;
        ////            }
        ////        }
        ////        if (!isExist)
        ////        {
        ////            listCart.Add(GetCartInfo());
        ////        }
        ////        Session["cp"] = listCart;
        ////    }
        ////    else
        ////    {
        ////        listCart = new List<CartInfo>();
        ////        listCart.Add(GetCartInfo());
        ////        Session["op"] = listCart;
        ////    }
        ////}
        ////protected CartInfo GetCartInfo()
        ////{
        ////    model.liberID = Convert.ToInt32(Request.QueryString["PID"]);
        ////    DataTable dt = bll.GetDataByID(model);//通过商品ID查询商品信息
        ////    CartInfo stu = new CartInfo();
        ////    return stu;
        ////}

        protected void Button1_Click(object sender, EventArgs e)
        {

           // AddCart();//调用购物车添加的方法
        }
    }
}